﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class HanhKiemData
    {
        DataService m_HanhKiemData = new DataService();

        public DataTable LayDsHanhKiem()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM HANHKIEM");
            m_HanhKiemData.Load(cmd);
            return m_HanhKiemData;
        }

        public void LuuHanhKiem(String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemHanhKiem");

            cmd.Parameters.Add("@TenHanhKiem", SqlDbType.NVarChar).Value = Ten;

            m_HanhKiemData.LoadProc(cmd);
        }

        public void UpdateHanhKiem(String MaHK, String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatHanhKiem");

            cmd.Parameters.Add("@MaHK", SqlDbType.NVarChar).Value = MaHK;
            cmd.Parameters.Add("@TenHK", SqlDbType.NVarChar).Value = Ten;

            m_HanhKiemData.LoadProc(cmd);
        }

        public void DeleteHanhKiem(String MaHK)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaHanhKiem");

            cmd.Parameters.Add("@MaHK", SqlDbType.Int).Value =Convert.ToInt32(MaHK);

            m_HanhKiemData.LoadProc(cmd);
        }
    }
}
